package com.thjk.bdf.system.service.impl;



import java.text.SimpleDateFormat;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.thjk.bdf.common.entity.ApplyOrder;
import com.thjk.bdf.system.service.CreditService;
import com.thjk.bdf.system.service.controller.BaseController;
import com.thjk.bdf.system.service.dao.ApplyOrderMapper;
import com.thjk.loan.management.common.page.TableDataInfo;

/**
 * 
 * @创建日期： 2019年12月18日
 * @author 束凯
 * @Description：授信信息后管服务
 */
@RestController
@RequestMapping("/credit")
public class CreditServiceImpl extends BaseController implements  CreditService{

	@Autowired
	private  ApplyOrderMapper  applyOrderMapper;
	
	@PostMapping("/list")
	@Override
	public TableDataInfo selectyPage(@RequestBody(required=false) ApplyOrder applyOrder) {
		startPage(applyOrder);
		List<ApplyOrder> orders = applyOrderMapper.selectByOrder(applyOrder);
		for (ApplyOrder order : orders) {
			SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			order.setApplyTime(formatter.format(order.getCreateTime()));
		}
		return getDataTable(orders);
	}

	@PostMapping("/selectById")
	@Override
	public ApplyOrder selectByPrimaryKey(Integer id) {
		// TODO Auto-generated method stub
		ApplyOrder order = applyOrderMapper.selectByPrimaryKey(id);
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		order.setApplyTime(formatter.format(order.getCreateTime()));
		return order;
	}

	@PostMapping("/export")
	@Override
	public List<ApplyOrder> selectExport(@RequestBody(required=false)ApplyOrder applyOrder) {
		// TODO Auto-generated method stub
		List<ApplyOrder> orders = applyOrderMapper.selectByOrder(applyOrder);
		for (ApplyOrder order : orders) {
			SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			order.setApplyTime(formatter.format(order.getCreateTime()));
		}
		return orders;
	}

	@PostMapping("/countExport")
	@Override
	public int countExport(@RequestBody(required=false)ApplyOrder applyOrder) {
		// TODO Auto-generated method stub
		return applyOrderMapper.selectCountByOrder(applyOrder);
	}

}
